const express = require("express");
const userCtrl = require("../controller/user");
const userValidator = require("../validator/user");
const auth = require("../middleware/auth");

const router = express.Router();

// 登录
router.post("/users/login", userValidator.login, userCtrl.login);
// 注册
router.post("/users", userValidator.register, userCtrl.register);
// 获取当前登录用户
router.get("/users", auth, userCtrl.getCurrentUser);
// 更新当前登录用户
router.put(
  "/users",
  auth,
  userValidator.uploadCurrentUser,
  userCtrl.uploadCurrentUser
);

module.exports = router;
